package com.csii.activiti.server.core.entity.db;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableName;
import com.csii.activiti.server.abstraction.entity.ActCallbackMessage;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.sql.Timestamp;
import java.util.Date;

@Data
@TableName("act_e_flow_callback")
@ApiModel("回调实体")
public class ActFlowCallbackEntity {
    @ApiModelProperty("回调主键")
    private String id;
    @ApiModelProperty("回调json数据")
    private String jsonData;

//    @ApiModelProperty("流程名称")
//    private String processName;
//    @ApiModelProperty("流程实例ID")
//    private String processInstanceId;
//    @ApiModelProperty("流程key")
//    private String processKey;
//    @ApiModelProperty("节点ID")
//    private String nodeId;
//    @ApiModelProperty("节点名称")
//    private String nodeName;

    @ApiModelProperty("回调类型")
    private String callbackType;
    @ApiModelProperty("回调时间")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    private Date callbackDate;
    @ApiModelProperty("错误消息")
    private String errorMessage;
    @ApiModelProperty("回调状态")
    private Integer callbackStatus;
    @ApiModelProperty("重试次数")
    private int retriesCount;
    @ApiModelProperty("回调url")
    private String callbackUrl;
    @ApiModelProperty("租户ID")
    private String actTenantId;

    public ActFlowCallbackEntity(){

    }

    public ActFlowCallbackEntity(ActCallbackMessage actCallbackMessage, String callbackType, String id, String callbackUrl){
        this.jsonData = JSONObject.toJSONString(actCallbackMessage);
        this.callbackDate = actCallbackMessage.getCurrentDate();
        this.callbackType = callbackType;
        this.id = id;
        this.callbackUrl = callbackUrl;
        this.callbackStatus = 0;
        this.actTenantId = actCallbackMessage.getTenantId();
    }

}
